import serve from '../../util/Http.js'
import qs from 'qs'
export default{
    // 管理员
    member(data){
        return serve({
            method:'get',
            params:{
                _gp:'admin.user',
                _mt:'getUser',
                nickname:data.name,
                pageNo:data.currentPage,
                limit:data.eachpage,
                id:data.id,
                level:data.level,
                gender:data.gender,
                status:data.status
            }
        })
    },
    // 删除
    deletes(id,nickname){
        console.log(id,nickname)
        return serve({
            method:'post',
            params:{
                _gp:'admin.user',
                _mt:'deleteUser',
                id:id,
                nickname:nickname
            }
        })
    },
    // 添加
    addition(data){
        return serve({
            method:'post',
            data:qs.stringify({
                _gp:'admin.user',
                _mt:'addUser',
                user:JSON.stringify({
                    ...data
                 })
            })
        })
    },
    // 编辑
    compile(data){
        return serve({
            method:'post',
            data:qs.stringify({
                _gp:'admin.user',
                _mt:'updateUser',
                user  : JSON.stringify({
                    nickname:data.nickname,
                    phone:data.phone,
                    level:data.level,
                    gender:data.gender,
                    status:data.status,
                    password:data.password,
                    id:data.id,
                    level:data.level == "普通会员" ? "0" : "1", //等级
                    gender:data.gender == "男" ? "2" : "1", //性别
                    status:data.status == "冻结" ? "0" : "1", //状态
                 })
            })
        })
    },
    // 授权
    accredit(data){
        console.log(data)
        return serve({
            method:'get',
            params:{
                _gp:'admin.user',
                _mt:'updateStatus',
                ...data
            }
        })
    },
}